home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9306 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.9 KB  |  81 lines

  1. Newsgroups: comp.lang.c
  2. Path: uu4news.netcom.com!zodiac!szh
  3. From: szh@zcon.com (Syed Zaeem Hosain)
  4. Subject: Re: Help creating dir's in C
  5. Message-ID: <1996Mar9.011243.28649@zcon.com>
  6. Sender: szh@zcon.com (Syed Zaeem Hosain)
  7. Nntp-Posting-Host: zodiac
  8. Reply-To: szh@zcon.com
  9. Organization: Z Consulting Group
  10. References: <4hlvu4$2hc@news.voicenet.com>
  11. Date: Sat, 9 Mar 1996 01:12:43 GMT
  12.  
  13. In article <4hlvu4$2hc@news.voicenet.com>, The Hermit <deaton@cygnus.rsabbs.com> writes:
  14. > Please help me! I'm really stuck on this program that I'm writing in C/C++. I using Borland's Turbo C/C++ compiler 3.0 for DOS.
  15. >What I need to know how to do is create and remove DOS directories WITHIN the C program. I've even tried using inline ASM routines
  16. >and calling BIOS interrupts, but I'm not too keen on ASM and I crashed my PC. :) Any replies are appreciated...
  17.  
  18. This is "off-topic" for this newsgroup. But I did not see anything in
  19. the FAQ to point you towards ... so here is something to check out: if
  20. you look in your compiler's library reference manual, you might find
  21. information on two functions called mkdir() and rmdir() ... I do not
  22. have your compiler so I cannot be more certain than this fairly general
  23. suggestion. If your library has these functions, they should work for
  24. your needs.
  25.  
  26. In addition, calls to the system() function may also work. This is what
  27. I tried on my Sun UNIX system, so this should give you some feeling for
  28. what is possible (this code does not do error checking, correct direc-
  29. tory name validation, checking the return value, etc. ... this is left
  30. as an exercise for you!):
  31.  
  32. zodiac{186}szh: cat foo.c
  33. #include <stdio.h>
  34.  
  35. main ( void )
  36. {
  37.   system ( "mkdir testdir" );
  38.   return (0);
  39. }
  40. zodiac{187}szh: cat bar.c
  41. #include <stdio.h>
  42.  
  43. main ( void )
  44. {
  45.   system ( "rmdir testdir" );
  46.   return (0);
  47. }
  48. zodiac{188}szh: gcc -o foo foo.c
  49. zodiac{189}szh: gcc -o bar bar.c
  50. zodiac{190}szh: ls -lF  
  51. total 50
  52. -rwxr-xr-x  1 szh         24576 Mar  8 17:10 bar*
  53. -rw-r--r--  1 szh            82 Mar  8 17:08 bar.c
  54. -rwxr-xr-x  1 szh         24576 Mar  8 17:10 foo*
  55. -rw-r--r--  1 szh            82 Mar  8 17:08 foo.c
  56. zodiac{191}szh: foo
  57. zodiac{192}szh: ls -lF
  58. total 51
  59. -rwxr-xr-x  1 szh         24576 Mar  8 17:10 bar*
  60. -rw-r--r--  1 szh            82 Mar  8 17:08 bar.c
  61. -rwxr-xr-x  1 szh         24576 Mar  8 17:10 foo*
  62. -rw-r--r--  1 szh            82 Mar  8 17:08 foo.c
  63. drwxr-xr-x  2 szh           512 Mar  8 17:10 testdir/
  64. zodiac{193}szh: bar
  65. zodiac{194}szh: ls -lF
  66. total 50
  67. -rwxr-xr-x  1 szh         24576 Mar  8 17:10 bar*
  68. -rw-r--r--  1 szh            82 Mar  8 17:08 bar.c
  69. -rwxr-xr-x  1 szh         24576 Mar  8 17:10 foo*
  70. -rw-r--r--  1 szh            82 Mar  8 17:08 foo.c
  71. zodiac{195}szh: 
  72.  
  73.                                 Z
  74.  
  75.  
  76. -- 
  77. -------------------------------------------------------------------------
  78. | Syed Zaeem Hosain          P. O. Box 610097            (408) 441-7021 |
  79. | Z Consulting Group        San Jose, CA 95161             szh@zcon.com |
  80. -------------------------------------------------------------------------
  81.